package org.linuxsogood.boot.jsoup;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author honway.liu
 * @date 2019/10/18 10:50 PM
 * @email gm100861@gmail.com
 * @blog http://linuxsogood.org
 */
public class JsoupDemo {

    public static void main(String[] args) throws IOException {

        String url = "http://218.14.207.76:8210/tt/business/bldr_vdetail-NzcyNDE1-gs-.html";
        Document document = Jsoup.connect(url).
                header("referer","http://218.14.207.76:8210/tt/business/bldr_vdetail-NzcyMTAw-gs-.html")
                .userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36")
                .cookie("ASPSESSIONIDSARCBCCS", "FJFDENHAFDEKEJGDDCLKOPMN; ASPSESSIONIDQARCBCCS=IJFDENHAFGFCMONCCHMHJEDB")
                .post();
        Elements elements = document.select("script");
        for (Element element : elements) {
            String x = element.toString();
            String regex = "\\s\\S.+client_stanID='(\\d+?)'";
            Matcher matcher = Pattern.compile(regex).matcher(x);
            while (matcher.find()) {
                System.out.println(matcher.group(1));
            }
        }
    }
}
